﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<script type="text/javascript">
    var keyValue = $.request("keyValue");
    $(function () {
        getItemList();
        if (keyValue != null) {
            GetEntity();
        }        
    });

    function GetEntity() {
        $.ajax({
            url: "/MyTask/MyCustomerInfo/GetEntity?keyValue=" + keyValue,
            dataType: "json",
            async: false,
            success: function (data) {
                console.log(data);
                $("#form1").formSerialize(data);
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var params = $("#form1").formSerialize();
        $.submitForm({
            url: "/MyTask/MyCustomerInfo/SubmitForm?keyValue=" + keyValue,
            param: params,
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }

    function getItemList() {
        $.ajax({
            url: "/MyTask/MyCustomerInfo/GetItemListJson",
            dataType: "json",
            async: false,
            success: function (data) {
                initControl(data)
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function initControl(data) {
        var citys = data.citys;
        for (var i = 0; i < citys.length; i++) {
            $("#F_CityId").append("<option value='" + citys[i].F_ItemCode + "'>" + citys[i].F_ItemName + "</option>");
        }

        var khdjs = data.khdjs;
        for (var i = 0; i < khdjs.length; i++) {
            $("#F_ClientLevel").append("<option value='" + khdjs[i].F_ItemCode + "'>" + khdjs[i].F_ItemName + "</option>");
        }

        var khlxs = data.khlxs;
        for (var i = 0; i < khlxs.length; i++) {
            $("#F_ClientType").append("<option value='" + khlxs[i].F_ItemCode + "'>" + khlxs[i].F_ItemName + "</option>");
        }       

        var gszws = data.gszws;
        for (var i = 0; i < gszws.length; i++) {
            $("#F_PositionId").append("<option value='" + gszws[i].F_ItemCode + "'>" + gszws[i].F_ItemName + "</option>");
        }

        var ssbms = data.ssbms;
        for (var i = 0; i < ssbms.length; i++) {
            $("#F_Department").append("<option value='" + ssbms[i].F_ItemCode + "'>" + ssbms[i].F_ItemName + "</option>");
        }
    }
    var count = 0;
    //function btn_add() {
    //    var html = "<tr>";
    //    html += "<td class=\"formTitle\">品牌/项目组</td>";
    //    html += "<td class=\"formValue\"><input id=\"F_ProjectName" + count + "\" name=\"F_ProjectName" + count +"\" type=\"text\" class=\"form- control required\" placeholder=\"请录入品牌/ 项目组\" /></td>";
    //    html += "<td class=\"formTitle\">所属行业</td>";
    //    html += "<td class=\"formValue\"><select id=\"F_IndustryId" + count + "\" name=\"F_IndustryId" + count +"\" class=\"form- control required\"><option value=\"\">==请选择所属行业==</option></select></td>";
    //    html += "<td class=\"formTitle\">联系人</td>";
    //    html += "<td class=\"formValue\">";
    //    html += "<input id=\"F_Contract" + count + "\" name=\"F_Contract" + count +"\" type=\"text\" class=\"form- control required\" placeholder=\"请录入联系人\" />";
    //    html += "</td>";
    //    html += "</tr>";
    //    $("#itemsTd").append(html);
    //    var html1 = "<tr>";
    //    html1 += "<td class=\"formTitle\">所属部门</td>";
    //    html1 += "<td class=\"formValue\"><select id=\"F_Department" + count + "\" name=\"F_Department" + count +"\" class=\"form- control\"><option value=\"\">==请选择所属部门==</option></select></td>";
    //    html1 += "<td class=\"formTitle\">公司职位</td>";
    //    html1 += "<td class=\"formValue\"><select id=\"F_PositionId" + count + "\" name=\"F_PositionId" + count +"\" class=\"form- control\"><option value=\"\">==请选择公司职位==</option></select></td>";
    //    html1 += "<td class=\"formTitle\">联系电话</td>";
    //    html1 += "<td class=\"formValue\"><input id=\"F_Phone" + count + "\" name=\"F_Phone" + count +"\" type=\"text\" maxlength=\"11\" minlength=\"11\" class=\"form- control required\" placeholder=\"请录入联系电话\" /></td>";
    //    html1 += "</tr>";
    //    $("#itemsTd").append(html1);
    //    var html2 = "<tr>";
    //    html2 += "<td class=\"formTitle\">公司邮箱</td>";
    //    html2 += "<td class=\"formValue\"><input id=\"F_Mail" + count + "\" name=\"F_Mail" + count +"\" type=\"email\" class=\"form- control\" placeholder=\"请录入公司邮箱\" /></td>";
    //    html2 += "<td class=\"formTitle\"></td>";
    //    html2 += "<td class=\"formValue\"></td>";
    //    html2 += "<td class=\"formTitle\"></td>";
    //    html2 += "<td class=\"formValue\"></td>";
    //    html2 += "</tr>";
    //    $("#itemsTd").append(html2);
    //    count = count + 1;
    //}
</script>

<form id="form1">
    <div style="padding-top: 5px;">
        <table id="form1" class="form">
            <tr>
                <td colspan="6" class="interval">客户信息</td>
            </tr>
            <tr>
                <td colspan="6">
                    <table class="form">
                        <tr>
                            <td class="formTitle">客户名称</td>
                            <td class="formValue"><input id="F_ClientName" name="F_ClientName" type="text" class="form-control required" placeholder="请录入客户名称" /></td>
                            <td class="formTitle">所在城市</td>
                            <td class="formValue">
                                <select id="F_CityId" name="F_CityId" class="form-control required">
                                    <option value="">==请选择城市==</option>
                                </select>
                            </td>
                            <td class="formTitle">客户级别</td>
                            <td class="formValue">
                                <select id="F_ClientLevel" name="F_ClientLevel" class="form-control required">
                                    <option value="">==请选择客户级别==</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">客户类型</td>
                            <td class="formValue">
                                <select id="F_ClientType" name="F_ClientType" class="form-control required">
                                    <option value="">==请选择客户类型==</option>
                                </select>
                            </td>
                            <td class="formTitle"></td>
                            <td class="formValue"></td>
                            <td class="formTitle"></td>
                            <td class="formValue"></td>
                        </tr>  
                    </table>
                </td>
            </tr>                    
            @*<tr>
                <td colspan="6" class="interval">项目组信息</td>
            </tr>*@
            @*<tr>
                <td colspan="6">
                    <table class="form" id="itemsTd">
                        <tr>
                            <td class="formTitle">品牌/项目组</td>
                            <td class="formValue">
                                <input id="F_ProjectName" name="F_ProjectName" type="text" class="form-control required" placeholder="请录入品牌/项目组" />
                            </td>
                            <td class="formTitle">所属行业</td>
                            <td class="formValue">
                                <select id="F_IndustryId" name="F_IndustryId" class="form-control required">
                                    <option value="">==请选择所属行业==</option>
                                </select>
                            </td>
                            <td class="formTitle">联系人</td>
                            <td class="formValue">
                                <input id="F_Contract" name="F_Contract" type="text" class="form-control required" placeholder="请录入联系人" />
                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">所属部门</td>
                            <td class="formValue">
                                <select id="F_Department" name="F_Department" class="form-control">
                                    <option value="">==请选择所属部门==</option>
                                </select>
                            </td>
                            <td class="formTitle">公司职位</td>
                            <td class="formValue">
                                <select id="F_PositionId" name="F_PositionId" class="form-control">
                                    <option value="">==请选择公司职位==</option>
                                </select>
                            </td>
                            <td class="formTitle">联系电话</td>
                            <td class="formValue">
                                <input id="F_Phone" name="F_Phone" type="text" maxlength="11" minlength="11" class="form-control required" placeholder="请录入联系电话" />
                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">公司邮箱</td>
                            <td class="formValue">
                                <input id="F_Mail" name="F_Mail" type="email" class="form-control" placeholder="请录入公司邮箱" />
                            </td>
                            <td class="formTitle"></td>
                            <td class="formValue"></td>
                            <td class="formTitle"></td>
                            <td class="formValue"></td>
                        </tr>
                    </table>                    
                </td>
            </tr>*@            
        </table>
    </div>
</form>
@*<table class="form">
    <tr id="btnInsertRow">
        <td class="formTitle"></td>
        <td class="formValue"></td>
        <td class="formTitle"></td>
        <td class="formValue"></td>
        <td class="formTitle"></td>
        <td class="formValue" style="float:right;">
            <div class="btn-group">
                <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-eraser"></i>新增项目组</a>
            </div>
        </td>
    </tr>
</table>*@
